﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using 纸片人.CalculateControls;
using 纸片人.win2dEffectControl.DataClass;


// The Templated Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234235

namespace 纸片人.win2dEffectControl
{
    public sealed class ChromaKeyEffectControl : EffectControl
    {
        private ColorPicker colorPicker;
        private Vector4Control colorHdrVector4Control;
        private CheckBox featherCheckBox;
        private CheckBox invertAlphaCheckBox;
        private TextBoxSlider toleranceTexBoxSlider;
        public override EffectOneSourceData OneEffetData { get; set; }

        public ChromaKeyEffectControl()
        {
            this.DefaultStyleKey = typeof(ChromaKeyEffectControl);
            
            OneEffetData = new ChromaKeyEffectData();
        }

        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            SetEffectName("颜色替换效果", "ChromaKeyEffect");

            colorPicker = GetTemplateChildFormName<ColorPicker>(nameof(colorPicker));
            CreateBinding(OneEffetData, "", nameof(ChromaKeyEffectData.Color), colorPicker, ColorPicker.ColorProperty);

            featherCheckBox = GetTemplateChildFormName<CheckBox>(nameof(featherCheckBox));
            SetCheckBox(featherCheckBox, OneEffetData, nameof(ChromaKeyEffectData.Feather));


            invertAlphaCheckBox = GetTemplateChildFormName<CheckBox>(nameof(invertAlphaCheckBox));
            SetCheckBox(invertAlphaCheckBox, OneEffetData, nameof(ChromaKeyEffectData.InvertAlpha));

            toleranceTexBoxSlider = GetTemplateChildFormName<TextBoxSlider>(nameof(toleranceTexBoxSlider));
            SetTextBoxSlider(toleranceTexBoxSlider, OneEffetData, nameof(ChromaKeyEffectData.Tolerance));
            colorHdrVector4Control = GetTemplateChildFormName<Vector4Control>(nameof(colorHdrVector4Control));
            SetVector4Control(colorHdrVector4Control, OneEffetData, nameof(ChromaKeyEffectData.ColorHdr));
        }

    }
}
